package com.liuzu.esys.controller;

/*
* 商品推送系统
* */


import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.Good;
import com.liuzu.esys.pojo.GoodPush;
import com.liuzu.esys.service.GoodPushService;
import com.liuzu.esys.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/goodpush")
public class GoodPushController {
    @Autowired
    private GoodPushService goodPushService;

    @RequestMapping("/goodPushList")
    //public LayuiPageVo<Student> studentPageData(Integer page,Integer limit){
    // 注意 这里的  @RequestParam 不能省略   省略的话就不能获取参数了
    public LayuiPageVo<GoodPush> studentPageData(@RequestParam Map<String,Object> params){
        System.out.println(params);
        return goodPushService.goodPushPageData(params);
    }


    @RequestMapping("/userPushList")
    //public LayuiPageVo<Student> studentPageData(Integer page,Integer limit){
    // 注意 这里的  @RequestParam 不能省略   省略的话就不能获取参数了
    public LayuiPageVo<GoodPush> studentPushPageData(@RequestParam Map<String,Object> params){
        System.out.println(params);
        return goodPushService.userPushPageData(params);
    }






    @RequestMapping("/deleteGoodPush")
    public R deleteGood(Integer id){
        int result = goodPushService.deleteGoodPush(id);
        if (result==1){
            return R.ok();
        }
        else {
            return R.error();
        }
    }

    @RequestMapping("/updateGoodPush")
    public R updateGood(GoodPush goodPush){
        System.out.println(goodPush);

        int result = goodPushService.updateGoodPush(goodPush);
        if(result==1){
            return R.ok();
        }else{
            return R.error();
        }
    }

    @RequestMapping("/addGoodPush")
    public R addGood(GoodPush goodPush){
        System.out.println(goodPush);

        int result = goodPushService.addGoodPush(goodPush);
        if(result==1){
            return R.ok();
        }else{
            return R.error();
        }
    }

}
